package com.cangchu.presenter;

import com.cangchu.db.domain.DataRep;
import com.cangchu.db.domain.Goods;
import com.cangchu.ui.fragment.GoodsInfoFragment;

import java.util.List;

/**
 * Created by Administrator on 2016/11/8.
 */
public class GoodsInfoPresenterImpl implements GoodsInfoPresenter {

    private DataRep dataRep;
    private GoodsInfoFragment goodsInfoFragment;

    public GoodsInfoPresenterImpl(GoodsInfoFragment goodsInfoFragment) {
        this.goodsInfoFragment = goodsInfoFragment;
        this.dataRep = DataRep.getInstance(goodsInfoFragment.getActivity());
    }


    @Override
    public void getGoodsInfo(String code) {
        List<Goods> goodsList = dataRep.getGoodses();
        for (Goods goods : goodsList) {
            if (goods.getCode().equals(code)) {
                goodsInfoFragment.CodeChange(goods);
                return;
            }
        }
        goodsInfoFragment.CodeChange(null);
    }

    @Override
    public void getBatchInfo(String code) {

    }
}
